<?php
/**
 * Created by PhpStorm.
 * User: linyh
 * Date: 2015/4/21
 * Time: 21:34
 */

class base extends Activity {
    // 上传图片，把图片放在picture字段
    function pictureTask($lowBrowser=false){
        $up=Uploader::init();
        $pic=PictureModule::init("picture");
        list($picData['message'],$picData['data'])=$up->upFile('picture', null, 'imageFile');
        if(strtolower($picData['message'])=='success'){
            $picData['state'] = 200;
            $picData['data']['photoId']=$pic->add($picData['data']['url'],$picData['data']['savePath'],$picData['data']['filename']);
        }else{
            $picData['state'] = 500;
        }
        //var_dump($_FILES);
        if( $lowBrowser ){
            //为低能浏览器设置 还没过滤..
            $dataString = json_encode($picData);
            echo "<script> window.top.window['lowBrowser'](".$dataString.");</script>";
        }else{
            View::displayAsJson($picData);    
        }
        
    }

    // 获取下一级地址信息
    function areaTask($pid){
        $areaMode=AreaModule::init();
        $result['state']=200;
        $result['data']['list']=$areaMode->getSon((int)$pid);
        View::displayAsJson($result);
    }

    // 获取完整地址信息
    function areaLineTask($id){
        $areaMode=AreaModule::init();
        $result['state']=200;
        $result['data']['list']=$areaMode->getFullAddress((int)$id);
        View::displayAsJson($result);
    }
}